<ul id="relatedproducts">
    <?php if (!empty($this->relatedIds)) : ?>
        <?php foreach ($this->relatedIds as $id) {
            $product = new RCMS_Object_Product_Product($id);
            if ($product->getId() > 0) : ?>
    <li>
        <?php 
            $prodPage = new RCMS_Object_Page_Page($product->getPageId());
            if ($prodPage->getId() > 0 && $prodPage->getUrl() != '') :?>
        <?php if ($this->withImg) : ?>
        <?php $photo = $this->siteUrl.$product->getPhoto(); ?>
        <img src="<?php echo $photo; ?>" alt="<?php echo $product->getName(); ?>" title="<?php echo $product->getName(); ?>" />
        <?php endif; ?>
        <a href="<?php echo $this->siteUrl.$prodPage->getUrl();?>.html"><?php echo $product->getName(); ?></a>
        <input type="checkbox" id="prod-<?php echo $product->getId();?>" onchange="($(this).attr('checked')==true)?addToCart('<?php echo $product->getId();?>'):removeFromCart('<?php echo $product->getId();?>')"/>
        <?php endif;?>     
    </li>
        <?php    endif;         }?>
    <?php endif ; ?>
</ul>